import { defineConfig } from 'vite'
import { fileURLToPath, URL } from "node:url";
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    host: "0.0.0.0",
    port: 3000,
    open: true,
    proxy: {
      "/api": {
        target:"http://localhost:8000",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, "/api"),
      },
    },
  },
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "@a": fileURLToPath(new URL("./src/api", import.meta.url)),
      "@c": fileURLToPath(new URL("./src/components", import.meta.url)),
      "@s": fileURLToPath(new URL("./src/store", import.meta.url)),
      "@u": fileURLToPath(new URL("./src/utils", import.meta.url)),
      "@p": fileURLToPath(new URL("./src/pages", import.meta.url)),
      "@t": fileURLToPath(new URL("./src/types", import.meta.url)),
    },
  },
});
